const Router = require("@koa/router");

const fileRouter = new Router({ prefix: "/upload" });

const {
	saveAvatarInfo,
	savePictureInfo
} = require("../controller/file.controller");

// 登录校验的中间件
const { verifyAuth } = require("../middleware/auth.middleware");

// 上传头像的中间件
const {
	avatarHandler,
	pictureHandler,
	pictureResize
} = require("../middleware/file.middleware");

// 上传头像
fileRouter.post("/avatar", verifyAuth, avatarHandler, saveAvatarInfo);

// 上传内容配图
fileRouter.post(
	"/picture",
	verifyAuth,
	pictureHandler,
	pictureResize,
	savePictureInfo
);

module.exports = fileRouter;
